package com.soft.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.soft.entity.Dept;
import com.soft.entity.User;
import com.soft.mapper.UserMapper;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public List<User> queryAll() {
        List<User> userList = userMapper.selectList(null);
        return userList;
    }

    public List<User> queryByName(String name) {
    	QueryWrapper<User> qw = new QueryWrapper();
        qw.eq("name", name);
        List<User> deptList = userMapper.selectList(qw);
        return deptList;
    }
    public int insertOne(String name,String age)
    {
    	User user = new User();
    	user.setName(name);
    	user.setAge(age);
    	int num = userMapper.insert(user);
    	return num;
    }
    public int deleteById(int id)
    {
    	User user = new User();
    	user.setId(id);
    	int num = userMapper.deleteById(user);
    	return num;
    }
    public int updateByName(String name)
	{
		UpdateWrapper<User> uw = new UpdateWrapper<>();
		uw.gt("name", name);
		User user = new User();
		user.setName("ljz");
		return userMapper.update(user,uw);
	}
}